home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
MPW_TOOL
/
TOOLS
/
TOOLS_WI
/
ICON_8
/
TESTS
/
SIEVE.ICN
< prev
next >
Wrap
Text File
|
1990-03-02
|
543b
|
21 lines
#
# S I E V E O F E R A T O S T H E N E S
#
# This program illustrates the use of sets in implementing the
# classical sieve algorithm for computing prime numbers.
procedure main()
local limit, s, i
limit := 100
s := set()
every insert(s,1 to limit)
every member(s,i := 2 to limit) do
every delete(s,i + i to limit by i)
delete(s,1)
primes := sort(s)
write("There are ",*primes," primes in the first ",limit," integers.")
write("The primes are:")
every write(right(!primes,*limit + 1))
end